<%@ page language="java" contentType="text/html; charset=utf-8"	pageEncoding="utf-8"%>
<%
	String id = (String) request.getAttribute("id");
%>
<html>
<head>


<script type="text/javascript">
	var id =<%=id%>	;
	var listPageUrl = "message/index.do";
	var infoUrl = "rest/messageInfo.do";
	var updateUrl = "rest/messageUpdate.do";
	var messageType;
	$(document).ready(function() {
		var data;
		$.get(infoUrl + "?id=" + id, function(result) {
			if (result.retCode == "0000") {
				data = result.data;				
				$('#fmMess').form('load', data);
			} else {
				$('#dg').datagrid('reload');
				$.messager.alert('操作提示', "加装数据失败", '加装数据失败');
			}
		});

		messageType = syncGetDictListByTypeName('messageType');
		
	})
	//end ready

	function updateMessage() {
		$('#fmMess').form('submit', {
			url : updateUrl,
			onSubmit : function() {
				return $(this).form('validate');
			},
			success : function(result) {
				var result = eval('(' + result + ')');
				if (result.retCode == '0000') {
					back(listPageUrl);
				} else {
					$.messager.show({
						title : 'Error',
						msg : result.retMsg
					});
				}
			}
		});
	}

	function backMessage(url) {
		$.get(url, {}, function(data) {
			$("#center").empty();
			$("#center").html(data);
			$.parser.parse($("#center"));
		});
	}
</script>
</head>
<body>


<div class="linkbar"><a>系统</a>/<a>消息模板管理</a>/<a>编辑消息模板</a></div>
	<!-- <div class="breadcrumb">系统 &gt;&gt; 消息模板管理 &gt;&gt; 编辑消息模板</div> -->
	<div id="div-edit" >
		<form id="fmMess" method="post" novalidate>
			<INPUT TYPE=hidden NAME=id VALUE="<%=id%>">
			<div class="fitem">
				<label>标题:</label> 
				<input name="title"
					   class="easyui-validatebox" 
					   data-options="required:true,validType:['length[1,40]']"/>
			</div>
			<div class="fitem">
				<label>类型:</label> 
				<select id="messageType" class="easyui-combobox"
					name="type" style="width:300px;" panelHeight="auto"
					data-options="valueField: 'dictValue',textField: 'dictName',
								data: messageType" />
			</div>
			<div class="fitem">
				<label>内容:</label> 
				<input name="content"
					   class="easyui-validatebox" 
					   data-options="required:true,validType:['length[1,40]']" />
			</div>
			<div class="fitem">
				<label>备注：</label> 
				<textarea name="remark" style="height:80px;width:300px;"
					   class="easyui-validatebox" 
					   data-options="validType:['length[1,5000]']" />
			</div>

		</form>
	</div>
	<div id="dlg-buttons">
		<a href="#" class="easyui-linkbutton" iconCls="icon-ok"
			onclick="updateMessage()">保存</a> <a href="#" class="easyui-linkbutton"
			iconCls="icon-cancel" onclick="backMessage(listPageUrl)">返回</a>
	</div>


</body>
</html>